package com.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dao.ArticleMapper;
import com.dao.SqlMapper;
import com.entity.Article;
import com.service.IArticleService;
import com.util.DateUtils;

/**
 * @项目名称：dream-face
 * @类名称：ArticleServiceImpl
 * @类描述：
 * @创建人：YangChao
 * @联系方式：18629233301@163.com
 * @创建时间：2017年3月6日 上午9:38:01
 * @version 1.0.0
 */
@Service("articleService")
public class ArticleServiceImpl implements IArticleService {

	@Autowired
	private ArticleMapper articleDao;
	@Autowired
	private SqlMapper sqlDao;

	@Override
	public List<Article> getArticleListByUserId(Integer createUserId) throws Exception {
		return sqlDao.getArticleListByUserId(createUserId);
	}

	@Override
	public void saveOrUpdate(Article t) throws Exception {
		t.setUpdateTime(DateUtils.getCurrentDate(DateUtils.YYYYMMDDHHMMSS));
		if (t.getId() != null) {
			articleDao.updateByPrimaryKeySelective(t);
		} else {
			t.setCreateTime(DateUtils.getCurrentDate(DateUtils.YYYYMMDDHHMMSS));
			articleDao.insertSelective(t);
		}

	}

	@Override
	public void removeById(Integer id) throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public Article findById(Integer id) throws Exception {
		return articleDao.selectByPrimaryKey(id);
	}

	@Override
	public List<Article> find(Article t) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getCount(Article t) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}

}
